<Query Kind="Program" />

void Main()
{
	Product productA = Factory.GetProduct("A");
	productA.MethodSame();
	productA.MethodDiff();

	Product productB = Factory.GetProduct("B");
	productB.MethodSame();
	productB.MethodDiff();
	
}

abstract class Product
{
	public void MethodSame()
	{
		Console.WriteLine("这里是公共的方法");
	}
	public abstract void MethodDiff();
}

class ProductA : Product
{
	public override void MethodDiff()
	{
		Console.WriteLine("这里是ProductA");
	}
}

class ProductB : Product
{
	public override void MethodDiff()
	{
		Console.WriteLine("这里是ProductB");
	}
}

class Factory
{
	public static Product GetProduct(string arg)
	{
		Product product = null;
		if (arg.Equals("A"))
		{
			product = new ProductA();
		}
		else if (arg.Equals("B"))
		{
			product = new ProductA();
		}
		return product;
	}
}
